package com.aspose.cells;

import java.util.ArrayList;

class zki extends zagm {
   ColorScale a;

   public zki(ColorScale var1, zaay var2, zfv var3, CellArea var4) {
      super(var2, var3, var4);
      this.a = var1;
   }

   private com.aspose.cells.a.d.zb a(com.aspose.cells.b.a.b.zq var1, double[] var2, int var3) {
      if (this.c == null) {
         this.d();
      }

      if (this.c.b() != 3) {
         return null;
      } else {
         double var4 = this.a(this.a.getMaxCfvo()).k();
         double var6 = this.a(this.a.getMinCfvo()).k();
         double var8 = 0.0D;

         try {
            if (var4 == var6) {
               if (((zyy)this.c).k() >= var4) {
                  var8 = 1.0D;
               } else {
                  var8 = 0.0D;
               }
            } else {
               var8 = (double)((float)((((zyy)this.c).k() - var6) / (var4 - var6)));
            }

            int var10 = (int)((double)((this.a.getMaxColor().getA() & 255) - (this.a.getMinColor().getA() & 255)) * var8 + (double)(this.a.getMinColor().getA() & 255));
            int var11 = (int)((double)((this.a.getMaxColor().getR() & 255) - (this.a.getMinColor().getR() & 255)) * var8 + (double)(this.a.getMinColor().getR() & 255));
            int var12 = (int)((double)((this.a.getMaxColor().getG() & 255) - (this.a.getMinColor().getG() & 255)) * var8 + (double)(this.a.getMinColor().getG() & 255));
            int var13 = (int)((double)((this.a.getMaxColor().getB() & 255) - (this.a.getMinColor().getB() & 255)) * var8 + (double)(this.a.getMinColor().getB() & 255));
            Color var14 = Color.fromArgb(255, var11, var12, var13);
            com.aspose.cells.a.d.zb var15 = new com.aspose.cells.a.d.zb();
            com.aspose.cells.a.d.zn var16 = new com.aspose.cells.a.d.zn(var1);
            var16.a((com.aspose.cells.b.a.b.zc)(new com.aspose.cells.b.a.b.zu(var14)));
            var15.a((com.aspose.cells.a.d.zl)var16);
            return var15;
         } catch (Exception var17) {
            return null;
         }
      }
   }

   Color a() {
      if (this.c == null) {
         this.d();
      }

      if (this.c.b() != 3) {
         return Color.getEmpty();
      } else {
         double var1 = this.a(this.a.getMaxCfvo()).k();
         double var3 = this.a(this.a.getMinCfvo()).k();
         double var5 = 0.0D;
         if (var1 == var3) {
            if (((zyy)this.c).k() >= var1) {
               var5 = 1.0D;
            } else {
               var5 = 0.0D;
            }
         } else {
            var5 = (double)((float)((((zyy)this.c).k() - var3) / (var1 - var3)));
         }

         int var7 = (int)((double)((this.a.getMaxColor().getA() & 255) - (this.a.getMinColor().getA() & 255)) * var5 + (double)(this.a.getMinColor().getA() & 255));
         int var8 = (int)((double)((this.a.getMaxColor().getR() & 255) - (this.a.getMinColor().getR() & 255)) * var5 + (double)(this.a.getMinColor().getR() & 255));
         int var9 = (int)((double)((this.a.getMaxColor().getG() & 255) - (this.a.getMinColor().getG() & 255)) * var5 + (double)(this.a.getMinColor().getG() & 255));
         int var10 = (int)((double)((this.a.getMaxColor().getB() & 255) - (this.a.getMinColor().getB() & 255)) * var5 + (double)(this.a.getMinColor().getB() & 255));
         Color var11 = Color.fromArgb(255, var8, var9, var10);
         return var11;
      }
   }

   Color b() {
      if (this.c == null) {
         this.d();
      }

      if (this.c.b() != 3) {
         return Color.getEmpty();
      } else {
         double var1 = this.a(this.a.getMaxCfvo()).k();
         double var3 = this.a(this.a.getMinCfvo()).k();
         double var5 = this.a(this.a.getMidCfvo()).k();
         double var7 = 0.0D;
         Color var9 = this.a.getMaxColor();
         Color var10 = this.a.getMinColor();
         double var11 = ((zyy)this.c).k();
         if (var11 >= var5) {
            var3 = var5;
            var10 = this.a.getMidColor();
         } else {
            var1 = var5;
            var9 = this.a.getMidColor();
         }

         if (var11 < var3) {
            return var10;
         } else if (var11 > var1) {
            return var9;
         } else {
            if (var1 == var3) {
               if (var11 == var1) {
                  var7 = 0.5D;
               } else if (var11 > var1) {
                  var7 = 1.0D;
               } else {
                  var7 = 0.0D;
               }
            } else {
               var7 = (double)((float)((var11 - var3) / (var1 - var3)));
            }

            int var13 = (int)((double)((var9.getA() & 255) - (var10.getA() & 255)) * var7 + (double)(var10.getA() & 255));
            int var14 = (int)((double)((var9.getR() & 255) - (var10.getR() & 255)) * var7 + (double)(var10.getR() & 255));
            int var15 = (int)((double)((var9.getG() & 255) - (var10.getG() & 255)) * var7 + (double)(var10.getG() & 255));
            int var16 = (int)((double)((var9.getB() & 255) - (var10.getB() & 255)) * var7 + (double)(var10.getB() & 255));
            Color var17 = Color.fromArgb(255, var14, var15, var16);
            return var17;
         }
      }
   }

   private com.aspose.cells.a.d.zb b(com.aspose.cells.b.a.b.zq var1, double[] var2, int var3) {
      if (this.c == null) {
         this.d();
      }

      if (this.c.b() != 3) {
         return null;
      } else {
         double var4 = this.a(this.a.getMaxCfvo()).k();
         double var6 = this.a(this.a.getMinCfvo()).k();
         double var8 = this.a(this.a.getMidCfvo()).k();
         double var10 = 0.0D;

         try {
            Color var12 = this.a.getMaxColor();
            Color var13 = this.a.getMinColor();
            Color var14 = Color.getEmpty();
            double var15 = ((zyy)this.c).k();
            if (var15 > var4) {
               var14 = Color.a(255, (Color)var12);
            } else if (var15 < var6) {
               var14 = Color.a(255, (Color)var13);
            } else {
               if (var15 >= var8) {
                  var6 = var8;
                  var13 = this.a.getMidColor();
               } else {
                  var4 = var8;
                  var12 = this.a.getMidColor();
               }

               if (var4 == var6) {
                  if (var15 == var4) {
                     var10 = 0.5D;
                  } else if (var15 > var4) {
                     var10 = 1.0D;
                  } else {
                     var10 = 0.0D;
                  }
               } else {
                  var10 = (double)((float)((var15 - var6) / (var4 - var6)));
               }

               int var17 = (int)((double)((var12.getA() & 255) - (var13.getA() & 255)) * var10 + (double)(var13.getA() & 255));
               int var18 = (int)((double)((var12.getR() & 255) - (var13.getR() & 255)) * var10 + (double)(var13.getR() & 255));
               int var19 = (int)((double)((var12.getG() & 255) - (var13.getG() & 255)) * var10 + (double)(var13.getG() & 255));
               int var20 = (int)((double)((var12.getB() & 255) - (var13.getB() & 255)) * var10 + (double)(var13.getB() & 255));
               var14 = Color.fromArgb(255, var18, var19, var20);
            }

            com.aspose.cells.a.d.zb var22 = new com.aspose.cells.a.d.zb();
            com.aspose.cells.a.d.zn var23 = new com.aspose.cells.a.d.zn(var1);
            var23.a((com.aspose.cells.b.a.b.zc)(new com.aspose.cells.b.a.b.zu(var14)));
            var22.a((com.aspose.cells.a.d.zl)var23);
            return var22;
         } catch (Exception var21) {
            return null;
         }
      }
   }

   public com.aspose.cells.a.d.zb a(com.aspose.cells.b.a.b.zq var1, double[] var2, int var3, int var4) {
      new ArrayList();

      try {
         return !this.a.a() ? this.a(var1, var2, var4) : this.b(var1, var2, var4);
      } catch (Exception var7) {
         return null;
      }
   }

   public boolean c() {
      return true;
   }
}
